import torch.nn as nn
import torch
from modules.models.backbones.mit import MixVisionTransformer
import torch.nn.functional as F
from ....backbones import BuildNormalization, BuildActivation
class GRFusion(nn.module):
    def __init__(self, in_channels,feats_channels, norm_cfg,act_cfg):
        super(GRFusion, self).__init__()
        self.blocks = nn.ModuleList()
        for i,in_channel in enumerate(in_channels):
            # cur_in_channel += in_channel
            self.blocks.append(nn.Sequential(
                nn.Conv2d(in_channel, feats_channels, kernel_size=1, stride=1, padding=0, bias=False),
                BuildNormalization(feats_channels, norm_cfg=norm_cfg),
                BuildActivation(act_cfg),
            ))

    def forward(self, feats):
        outs = []
        for idx, feat in enumerate(list(feats)):
            outs.append(F.interpolate(self.convs[idx](feat), size=feats[0].shape[2:], mode='bilinear'))
        feats = torch.cat(outs, dim=1)
        return feats
